﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Diagnostics;
using System.Windows.Forms;
using System.Linq;
using System.Text;

namespace SetupAction
{
    [RunInstaller(true)]
    public class InstallAction : Installer
    {
        public InstallAction()
            : base()
        {
        }

       public static void Main()
        {
           
        }

        protected override void OnBeforeUninstall(IDictionary savedState)
        {
            try
            {

                Process p = new Process();
                InstallContext cont = this.Context;
                ProcessStartInfo inf = new ProcessStartInfo("cmd.exe");
                p.StartInfo = inf;
                p.Start();
            }
            catch (Exception)
            {
            }
        }

        protected override void OnBeforeInstall(IDictionary savedState)
        {
           
        }

        public override void Commit(IDictionary savedState)
        {
            string locationDir = System.IO.Path.GetDirectoryName(Context.Parameters["assemblypath"]);
            string fileName = System.IO.Path.Combine(locationDir, "TelPhoneF.exe");

            if (System.IO.File.Exists(fileName))
            {
                Process p = new Process();
                InstallContext cont = this.Context;
                ProcessStartInfo inf = new ProcessStartInfo(fileName);
                p.StartInfo = inf;
                p.Start();
            }
        }

        protected override void OnCommitting(IDictionary savedState)
        {
            string location = Context.Parameters["assemblypath"];
        }

        protected override void OnCommitted(IDictionary savedState)
        {
        }
    }

}
